//
//  HMGoodsViewController.m
//  localLife
//
//  Created by Limonwei on 15/11/27.
//  Copyright © 2015年 heima. All rights reserved.
//

#import "HMGoodsViewController.h"
#import "HMGoodsHeaderTableViewCell.h"
#import "HMGoodsModel.h"

@interface HMGoodsViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)HMGoodsHeaderTableViewCell *headerView;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property(nonatomic,strong)HMGoodsModel *model;

@end

static NSString *ID = @"HMGoodsHeaderTableViewCell";

@implementation HMGoodsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.titltLabel.text = @"商品详情";
    
    self.rightButton.hidden = YES;
    
    _headerView = [[[UINib nibWithNibName:@"HMGoodsHeaderTableViewCell" bundle:nil]instantiateWithOwner:self options:nil]objectAtIndex:0];
    
    [_headerView layoutIfNeeded];
    
    _tableView.tableHeaderView = _headerView;
    
    _tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    
}

-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    
    [self getData];
    
}

-(void)getData{
    
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    
 
    [HMAFHTTPClient getGoodsWithParams:param withSuccessBlock:^(HMGoodsModel *model) {
        //
        _model = model;
        
        [_tableView reloadData];
        
    } withFailedBlock:^(NSError *error) {
        //
    }];
    
}

-(void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
    
    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    
    [app.tabbar showOrHiddenTabbarView:NO];

    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return [UITableViewCell new];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
